/*
 * Task.h
 *
 *  Created on: 19.11.2012
 *      Author: Lapchinskiy
 */

#ifndef TASK_H_
#define TASK_H_
//#include "Global_types.h"
typedef enum {ENABLED,SUSPENDED, DISABLED}TaskStatus;
static const char* TaskStatusToString[] ={"ENABLED","SUSPENDED", "DISABLED"};
class Task : public Block{
private:
	static uint8_t taskCounter;
	uint8_t id;
	Condition<volatile unsigned int> *conditionToRun;
	void *callbackArgs;
	Block *nextBlock;
	ErrorCode errorCode;
	TaskStatus status;

public:
	static ModuleType moduleType;
	LogRecord logrec;
	Task();
	ErrorCode (*callbackFunc)(void* args);
	Task(char* name, ErrorCode (*callBack)(void* args), void* args,
			TaskStatus enabled);
	ErrorCode setNexBlock(Block* nextBlock);
	ErrorCode Enable(void);
	ErrorCode Disable(void);
	TaskStatus GetStatus(void);
	ErrorCode CallbackRun(void *args);
	Block* step(void);
	void* getCallbackArgs() const {
		return callbackArgs;
	}
	uint8_t getId() const {
		return id;
	}
        ~Task();
};
#endif /* TASK_H_ */
